package com.Java.train.business.controller;

import com.Java.train.common.response.CommonResp;
import com.Java.train.business.entity.DTO.ConfirmOrderDTO;
import com.Java.train.business.req.ConfirmOrderQueryReq;
import com.Java.train.common.response.PageResp;
import com.Java.train.business.entity.ConfirmOrder;
import com.Java.train.business.service.ConfirmOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;

/**
* @author luomoxingchen
* @since 2024-10-04
*/
@RestController
@RequestMapping("/admin/confirm-order")
public class ConfirmOrderAdminController {

    @Autowired
    private ConfirmOrderService confirmOrderService;


    @GetMapping("/query-list")
    @ApiOperation("ConfirmOrder查询全部")
    public CommonResp< PageResp<ConfirmOrderDTO>> queryList(@Valid ConfirmOrderQueryReq confirmOrderQueryReq){
        PageResp<ConfirmOrderDTO> list = confirmOrderService.queryList(confirmOrderQueryReq);
        return new CommonResp<>(list);
    }

    @PostMapping("/save")
    @ApiOperation("ConfirmOrder修改")
    public CommonResp<Object> update(@Valid @RequestBody ConfirmOrder confirmOrder) {
        return confirmOrderService.modify(confirmOrder);
    }


    @DeleteMapping(value = "/delete/{ids}")
    @ApiOperation("ConfirmOrder删除(单个条目)")
    public CommonResp<Object> remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        return confirmOrderService.remove(ids);
    }
}
